function [OUT_Blocks N_Blocks] = HF_Blocking(IN_Bits,Rate,Interleaver_L)

%*------------------------------------------- HF_Blocking --------------------------------------------%
%
% [OUT_Blocks N_Blocks] = HF_Blocking(IN_Bits,Rate,Interleaver_L)
%
% the function that divides the input raw bits (IN_Bits) into blocks (OUT_Blocks) dependent on the
% (Rate) and the Interleaver length (Interleaver_L), and the number of the blocks is (N_Blocks).
% the function will pad the input data to get an integer number of the
% blocks as it mentioned in the standard (page:109)
%
%*-------------------- BlOCK SIZE AS FN OF DATA RATE AND INTERLEAVER LENGTH -----------------%
%
%                                       INTERLEAVER LENGTH IN FRAMES 
%                           
%                       1           3          9            18         36            72      
%DATA RATE         
%
%  3200                 384        1152       3456         6912       13824         27648
%  4800                 576        1728       5184         10368      20736         41472
%  6400                 768        2304       6912         13824      27648         55296
%  8000                 960        2880       8640         17280      34560         69120
%  9600                 1152       3456      10368         20736      41472         82944
%
%*----------------------------------------------------------------------------------------------------%

[Block_Size] = HF_Get_Blocksize(Rate,Interleaver_L);
N_Blocks = ceil(length(IN_Bits)/Block_Size);
Pad = N_Blocks*Block_Size-length(IN_Bits);
OUT_Blocks = [IN_Bits zeros(1,Pad)];

OUT_Blocks = reshape(OUT_Blocks,Block_Size,N_Blocks)';
%*----------------------------------------------------------------------------------------------------%


end


